<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html class="chrome csstransforms3d csstransitions">
  <head>
    <title><?php echo ((isset($seo["title"]) && ($seo["title"] !== ""))?($seo["title"]):"选礼物，上哇礼！只为Ta的惊喜~"); ?> - 哇礼网</title>
    <meta name="keywords" content="<?php echo ((isset($seo["keywords"]) && ($seo["keywords"] !== ""))?($seo["keywords"]):"礼物，创意礼物，精选礼物"); ?>">
    <meta name="description" content="<?php echo ((isset($seo["description"]) && ($seo["description"] !== ""))?($seo["description"]):"哇礼网精选好礼推荐平台，10000+礼物达人为你精选的创意礼物，解决你为不同对象不同节日场合不同挑选礼物的烦恼。选礼物，上哇礼，百分百惊喜！"); ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="/wowshi/Public/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="/wowshi/Public/css/font-awesome.min.css" rel="stylesheet" media="screen">
    <link href="/wowshi/Public/css/public.css" rel="stylesheet" media="screen">
    <!--[if lt IE 9]>
        <script src="/wowshi/Public/js/assets/libs/html5shiv.js?2.4.6.4"></script>
    <![endif]-->
    <!--[if IE 8]>
        <script src="/wowshi/Public/js/assets/libs/respond.min.js?2.4.6.4"></script>
    <![endif]-->
    <script src="/wowshi/Public/js/jquery/jquery-1.11.1.min.js"></script>
    <script src="/wowshi/Public/js/bootstrap.js"></script>
    <?php
 $user_id = $is_login = is_login(); $user_info = session('user_auth'); ?>
    <script type="text/javascript">
      var isLogin = <?php echo $is_login ? 1 : 0; ?>
    </script>
  </head>
  <body class="index">
  	<header class="header">
      <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
      	<div class="navbar-header">
          <a href="//wowli.net" class="navbar-brand">哇礼网-选礼物，上哇礼，只为Ta的惊喜！</a>
          <button class="navbar-toggle" data-target=".navbar-collapse" data-toggle="collapse" type="button">
            <span class="sr-only">切换导航</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <nav class="collapse navbar-collapse pull-left">
          <ul class="nav navbar-nav">
            <li><a href="http://wowli.net/bbs/" target="_blank">花园</a></li>
            <li><a href="#">抽屉</a></li>
            <!-- <li><a href="#">杂志</a></li>
            <li><a href="#">小组</a></li>
            <li><a href="#">经验</a></li> -->
          </ul>
        </nav>
        <form action="" class="navbar-form navbar-left hidden-xs hidden-sm" role="search">
          <div class="form-group">
            <input type="text" class="form-control js-search" name="q" placeholder="搜好礼，搜惊喜" autocomplete="off"/>
            <button class="button fa fa-search" type="submit"></button>
          </div>
        </form>
        <!--用户登录后的信息和操作-->
        <div class="nav-misc <?php if(!$is_login) echo 'hidden';?>">
            <?php if(!empty($user_info)): ?><ul class="nav-misc-list" style="margin-bottom:0px;">
                <li class="nav-misc-item nav-profile">
                    <a class="profile-link" href="/wowshi/wower/<?php echo (think_encrypt($user_info["uid"])); ?>">
                        <img width="34" height="34" src="/wowshi/Public/Uploads/<?php echo ((isset($user_info["avatar"]) && ($user_info["avatar"] !== ""))?($user_info["avatar"]):"default_avatar.jpg"); ?>" alt="<?php echo ($user_info["user_name"]); ?>">
                        我的哇礼
                    </a>
                </li>
                <li class="nav-misc-item enterances">
                    <i class="fa fa-plus J_UserAction"></i>
                    <div class="publish-enterances-wrap J_ActionWrap hidden">
                        <ul class="publish-enterances">
                            <li><a href="javascript:;" rel="nofollow"><i class="icon fa fa-paper-plane-o"></i>发布惊喜</a></li>
                            <li><a href="javascript:;" rel="nofollow"><i class="icon fa fa-pencil-square-o"></i>贡献攻略</a></li>
                        </ul>
                        <i class="icon-wrap"></i>
                        <i class="icon-inner"></i>
                    </div>
                </li>
            </ul><?php endif; ?>
        </div>
        <!--用户操作完成-->
        <ul class="nav user-nav pull-right <?php if($is_login) echo 'hidden';?>">
          <ul class="nav nav-login">
            <li><a href="" class="login" data-toggle="modal" data-target="#login-modal">登录</a></li>
            <li><a href="#" class="reg" data-toggle="modal" data-target="#login-modal">注册</a></li>
          </ul>
        </ul>
      </div>
      </nav>
  	</header>
  <link href="/wowshi/Public/css/category.css" rel="stylesheet" media="screen">
	<div class="container">
      <div class="row">
        <div class="">
          <div id="sub-nav" class="col-md-12">
            <div class="primary-categories">
                <div class="ui-select">
                    <span class="ui-select-label" data-value="<?php echo ($cate_info["id"]); ?>"><?php echo ($cate_info["cate_name"]); ?><i class="fa fa-caret-down"></i></span>
                    <ul class="ui-select-options">
                        <!-- <li data-value="1"><a href="/category/nvzhuang/">女装</a></li>
                        <li data-value="50"><a href="/category/nvxie/">女鞋</a></li>
                        <li data-value="83"><a href="/category/nanzhuang/">男装</a></li>
                        <li data-value="110"><a href="/category/nanxie/">男鞋</a></li>
                        <li data-value="137"><a href="/category/xiangbao/">箱包</a></li>
                        <li data-value="184"><a href="/category/peishi/">配饰</a></li>
                        <li data-value="222"><a href="/category/jiajuzhuangshi/">家居装饰</a></li>
                        <li data-value="349"><a href="/category/meizhuang/">美妆</a></li>
                        <li data-value="398"><a href="/category/meishi/">美食</a></li>
                        <li data-value="437"><a href="/category/shuma/">数码</a></li>
                        <li data-value="476"><a href="/category/huwai_yundong/">户外/运动</a></li>
                        <li data-value="598"><a href="/category/liwu/">礼物</a></li>
                        <li data-value="607"><a href="/category/riyongbaihuo/">日用百货</a></li> -->
                    </ul>
                </div>
            </div>
            <div class="secondary-categories layout-54 row">
                <div class="column column-hot col-md-3">
                    <div class="column secondary-category hot">
                        <span class="secondary-category-name">热门</span>
                        <ul class="tertiary-category-items">
                            <li class="tertiary-category-item">
                                <a href="javascript:;">日系</a>
                            </li>
                            <li class="tertiary-category-item">
                                <a href="javascript:;">外贸原单</a>
                            </li>
                            <li class="tertiary-category-item">
                                <a href="javascript:;">衬衫</a>
                            </li>
                            <li class="tertiary-category-item">
                                <a href="javascript:;">卫衣</a>
                            </li>
                            <li class="tertiary-category-item">
                                <a href="javascript:;">外套</a>
                            </li>
                            <li class="tertiary-category-item">
                                <a href="javascript:;">西装</a>
                            </li>
                            <li class="tertiary-category-item">
                                <a href="javascript:;">牛仔裤</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <?php
 $start = 0; $page = 3; $count = ceil(count($sub_nav) / 3); for ($i=1; $i <= $count; $i++) { $max = $i*$page; echo "<div class='column col-md-9'>" ."<div class='cate-row row'>"; foreach ($sub_nav as $k => $v) { if ($k >= $start && $k <$max) { echo "<div class='column secondary-category col-md-4'>" ."<span class='secondary-category-name'>".$v['cate_name']."</span>"; if (isset($v['child']) && count($v['child'])) { echo "<ul class='tertiary-category-items'>"; foreach ($v['child'] as $kk => $vv) { echo "<li class='tertiary-category-item'>" ."<a href='".$vv['id']."'>".$vv['cate_name']."</a></li>"; } echo "</ul>"; } echo "</div>"; } } $start = $max; echo "</div></div>"; } ?>
            </div>
            <div class="toggle-category">
                <a href="javascript:;" class="js-toggle toggle-full">查看全部分类<i class="fa fa-caret-down"></i></a>
                <a href="javascript:;" class="js-toggle toggle-part hidden">收起全部<i class="fa fa-caret-up"></i></a>
            </div>
          </div>
        </div>  
      </div>
    </div>
    <div class="container">
      <div class="row food_con">
        <?php if(is_array($goods_list)): foreach($goods_list as $key=>$goods): $path = "Public/Uploads/"; list($width, $height) = getimagesize($path.$goods['cover']); if ($height > 203) { $gap = $height - 203; $style = 'margin-top:'.(-$gap/2)."px"; } ?>
          <div class="col-md-4 col-sm-6">
            <div class="card-item">
              <div class="card-main">
                <div class="card-hd">
                  <div class="img">
                      <!-- <span class="price-icon free">
                        免费
                      </span> -->
                      <a href="<?php echo U('goods/'.$goods['id']);?>">
                        <img class="img-responsive" src="/wowshi/Public/Uploads/<?php echo ($goods["cover"]); ?>" style="<?php echo $style;?>">
                      </a>
                    </div>
                    <span class="commodity-price">￥<?php echo ($goods["cost_price"]); ?></span>
                </div>
                <div class="card-bd">
                  <h2 class="story-title" title="<?php echo ($goods["title"]); ?>">
                      <a target="_blank" href="<?php echo U('goods/'.$goods['id']);?>"><?php echo ($goods["title"]); ?></a>
                  </h2>
                  <div class="author-box">
                    <a class="author-avatar-link" href="#">
                        <img width="24" height="24" src="/wowshi/Public/images/avatar_5.jpg" alt="哇礼" title="哇礼">
                    </a>
                    <a href="#">哇礼小编</a>&nbsp;发布
                  </div>
                  <div class="story-quote">
                      <q class="quote"><?php echo ((isset($goods["why_recommend"]) && ($goods["why_recommend"] !== ""))?($goods["why_recommend"]):"Ta暂时还没有写推荐语"); ?></q>
                  </div>
                  <div class="story-info" data-eqid="3878709">
                      <ul class="stats-list">
                          <li class="doulist-count">加入抽屉&nbsp;<?php echo ($goods["add2drawer_count"]); ?></li>
                          <li class="like">喜欢&nbsp;<?php echo ($goods["like_count"]); ?></li>
                          <li class="post">评论&nbsp;<?php echo ($goods["commnet_count"]); ?></li>
                      </ul>
                  </div>
                </div>    
              </div>
              <div class="card-extra">
                <div class="card-actions" style="display: none;">
                  
                </div>
              </div>
            </div>
          </div><?php endforeach; endif; ?>        
      </div>
    </div>
<footer id="footer">
    <div class="container">
      <div class="row">
        <span id="icp" class="pull-left gray-link">
            © 2005－2015 wowli.com, all rights reserved
        </span>
        <a href="javascript:;" style="display: none;"></a>
        <span class="pull-right">
            <a href="javascript:;">关于哇礼</a>
            · <a href="javascript:;">在哇礼工作</a>
            · <a href="javascript:;">联系我们</a>
            · <a href="javascript:;">免责声明</a>
            · <a href="javascript:;">帮助中心</a>
            · <a href="javascript:;">移动应用</a>
        </span>       
      </div>
    </div>
  </footer>
  <!-- 登录model开始 -->
  <div class="modals">
    <div class="modal fade" id="login-modal">
        <div class="modal-dialog_wrapper">
            <div class="modal-dialog modal-dialog--front modal-dialog--signin">
                <div class="modal-content">
                    <button class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                    <div class="modal-body">
                        <form id="login_form" class="simple_form new_user" action="<?php echo U('user/Index/login');?>" accept-charset="UTF-8" data-remote="true" method="post" novalidate="true">
                            <input name="utf8" type="hidden" value="✓">
                            <legend>登录</legend>
                            <div class="form-main">
                                <div class="form-group col-sm-6">
                                    <label class="sr-only">邮件地址</label>
                                    <input required="required" placeholder="邮件地址" class="form-control" data-message-error="邮箱格式错误" type="email" name="user[email]" id="login_email" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="sr-only">密码</label>
                                    <input required="required" placeholder="密码" class="form-control" type="password" name="user[password]" id="login_password" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <input type="hidden" name="redirect_from" id="redirect_from">
                            </div>
                            <div class="form-group addon clearfix">
                                <div class="checkbox pull-left" id="remember_me">
                                    <label>
                                        <input name="user[remember_me]" type="hidden" value="0">
                                        <input type="checkbox" value="1" checked="checked" name="user[remember_me]" id="user_remember_me">记住我</label>
                                </div>
                                <a class="pull-right" data-toggle="modal" data-dismiss="modal" href="#find_password_modal">
                                <i class="fa fa-question-circle"></i>忘记密码？</a>
                            </div>
                            <div class="form-group form-results hidden" id="sign_in_alert_field">用户名或密码错误，请重新输入</div>
                            <div class="form-group form-actions">
                                <input type="submit" name="commit" value="登录" class="btn btn--blue_light" data-category="user" data-action="login" data-label="email">
                            </div>
                        </form>
                        <section class="auth">
                            <h6>使用社交账号登录</h6>
                            <p>
                            <a class="btn btn--icon btn--blue_light" title="用微信登录" data-category="user" data-action="login" data-label="wechat" href="/users/auth/wechat_web?state=%2Fdiscover"><i class="fa fa-weixin"></i></a>
                            <a class="btn btn--icon btn--blue_light" title="用微博登录" data-category="user" data-action="login" data-label="weibo" href="/users/auth/weibo?state=%2Fdiscover"><i class="fa fa-weibo"></i></a>
                            </p>
                        </section>
                        <footer class="section-footer"><a class="modal-flipper" href="#">注册<em class="logo">猫耳</em><i class="fa fa-angle-right"></i></a></footer>
                    </div>
                </div>
            </div>
            <div class="modal-dialog modal-dialog--back modal-dialog--signup">
                <div class="modal-content">
                    <button class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                    <div class="modal-body">
                        <form id="signup_form" class="simple_form new_user" action="<?php echo U('User/Index/register');?>" accept-charset="UTF-8" data-remote="true" method="post" novalidate="true">
                            <input name="utf8" type="hidden" value="✓">
                            <legend>注册</legend>
                            <div class="form-main">
                                <div class="form-group col-sm-6">
                                    <label class="sr-only" for="user_name">昵称</label>
                                    <input placeholder="用户名（少于 3~20 个字符）" class="form-control" required="required" maxlength="20" data-message-error="用户名必须介于介于 3~20个字符" size="20" type="text" value="" name="user[user_name]" id="user_name" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="form-group col-sm-6">
                                    <label class="sr-only" for="user_email">邮件地址</label>
                                    <input placeholder="邮件地址" class="form-control" required="required" data-message-error="邮箱格式错误" type="email" name="user[email]" id="user_email" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="clearfix"></div>
                                <div class="form-group col-sm-6">
                                    <label class="sr-only" for="user_password">密码</label>
                                    <input placeholder="密码（至少 6 个字符）" class="form-control" required="required" minlength="6" data-message-error="密码至少 6 个字符" type="password" name="user[password]" id="user_password" data-event="validate"><span class="button--clear fa fa-times"></span>
                                    <ul class="help-block"></ul>
                                </div>
                                <div class="form-group col-sm-6 signup_form-captcha">
                                    <label class="sr-only" for="captcha">验证码</label>
                                    <div class="input-group">
                                        <input type="text" name="captcha" id="captcha" autocomplete="off" required="required" class="form-control" data-parent=".form-group" placeholder="输入验证码" data-event="validate">
                                        <input type="hidden" name="captcha_key" id="simple-captcha-hidden-field-simple_captcha-28e145c6347" value="28e145c634754b73369a62a7156e795d0f880b66">
                                        <div class="input-group-addon" style="padding:0px;">
                                            <a rel="nofollow" title="换一张" data-remote="true" href="javascript:;" onclick="this.children[0].src='/wowshi/index/get_code?id='+Math.random()+1"><img src="/wowshi/index/get_code" id="simple_captcha-28e145c6347" alt="captcha" class="js-lazy" data-original=""  style="visibility: visible; display: inline;width:100px;height:44px;"></a>
                                        </div>
                                    </div>
                                    <ul class="help-block"></ul>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <div class="checkbox text-center">
                                    <label>
                                        <input type="checkbox" name="agreement" id="user_agreement" value="true" checked="checked">同意<a target="_blank" href="/user_agreement">《&nbsp;<em class="logo">猫耳</em>&nbsp;用户协议》</a></label>
                                </div>
                            </div>
                            <input type="hidden" name="path" id="path" value="/discover">
                            <input type="hidden" name="redirect_from" id="redirect_from">
                            <div class="form-group form-actions">
                                <input type="submit" name="commit" value="注册" class="btn btn--blue_light" data-category="user" data-action="register" data-label="email">
                            </div>
                        </form>
                        <section class="auth">
                            <h6>使用社交账号登录</h6>
                            <p>
                              <a class="btn btn--icon btn--blue_light" title="用微信登录" data-category="user" data-action="login" data-label="wechat" href="/users/auth/wechat_web?state=%2Fdiscover"><i class="fa fa-weixin"></i></a>
                              <a class="btn btn--icon btn--blue_light" title="用微博登录" data-category="user" data-action="login" data-label="weibo" href="/users/auth/weibo?state=%2Fdiscover"><i class="fa fa-weibo"></i></a>
                            </p>
                        </section>
                        <footer class="section-footer"><a class="modal-flipper" href="#"><i class="fa fa-angle-left"></i>登录<em class="logo">猫耳</em></a></footer>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal" id='add_drawer'>
        <div class="modal-wrapper">
            <div class="modal-dialog modal-dialog-drawer">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title box-title">添加好礼到抽屉</h4>
                    </div>
                    <div class="modal-body">
                        <div class="preview">
                            <img class="img-responsive" src="" id='J_goodsCoverPreview' data-goods-id=''>
                            <div style="display: block" class="stop"></div>
                        </div>
                        <div class="right-part">
                            <div class="board-list use-default-board inited" data-board-id="">
                                <div class="current">
                                    <div class="name"></div>
                                    <div class="arrow"></div>
                                </div>
                                <div style="display:none" class="drop-list">
                                    <div class="boards">
                                        <div class="group recent">
                                            <div class="side-title"></div>
                                            <div class="selections">
                                                <?php if(is_array($drawer_list)): foreach($drawer_list as $key=>$vo): ?><a title="<?php echo ($vo["title"]); ?>" data-board-id="<?php echo ($vo["id"]); ?>" class="board"><?php echo ($vo["title"]); ?></a><?php endforeach; endif; ?>
                                            </div>
                                        </div>
                                        <!-- <div class="group">
                                            <div class="side-title">
                                                <div class="icon">D</div>
                                            </div>
                                            <div class="selections">
                                            <a title="灯具" data-board-id="24039054" class="board">灯具</a>
                                            </div>
                                        </div> -->
                                    </div>
                                    <div style="display: none" class="filtrate">
                                    	<div class="group create">
                                    	    <div class="side-title"></div>
                                    	    <div class="selections"><a data-name="" class="board create-board selected" id="create_new_board">创建画板“<span id="new_board_name"></span>”</a></div>
                                    	</div>
                                    	<div class="group">
                                    	    <div class="side-title"></div>
                                    	    <div class="selections"></div>
                                    	</div>
                                    </div>
                                    <div class="filter">
                                        <input type="text" placeholder="快速筛选/创建抽屉" class="clear-input" id="filter_create_board">
                                    </div>
                                </div>
                            </div>
                            <div class="text-block">
                                <textarea class="clear-input description" autocomplete="off"></textarea>
                                <ul class="ac-choices" style="display: none; z-index: 42; opacity: 0;"></ul>
                                <div class="tag-bar">
                                    <div class="normal" style="display: none;"><span class="title">推荐标签</span><span class="tags"></span></div>
                                    <div style="display: none" class="more"><span class="title">更多标签</span><span class="tags"></span></div>
                                    <div style="display: block;" class="tip">通过给采集添加 #标签#，更好地整理采集</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer bottom-part">
                        <div class="shares"><span>分享到：</span>
                            <div data-key="weibo" data-flag="1" class="share weibo active">
                            <div class="selection"></div>新浪微博</div>
                        </div>
                        <div class="buttons">
                            <a href="javascript:;" class="action btn btn18 rbtn J_DrawrAddGoods" style="color:#fff;"><span class="text"> 发布</span></a>
                        </div>
                    </div>
                </div><!-- /.modal-content -->
            </div>
        </div>
    </div>
  </div>
  <!-- 登录model结束 -->
  </body>
  <script type="text/javascript">
    var api = {
        "loginUrl"       : '<?php echo U('User/login');?>',
        "registerUrl"    : '<?php echo U('User/register');?>',
        "createBoardUrl" : '<?php echo U('Drawer/async_create_drawer');?>',
        'addDrawerGoods' : '<?php echo U('Drawer/drawer_add_goods');?>',
    };

    $(function() {
      $('.modal-flipper').click(function() {
        if($('.modal-dialog_wrapper').hasClass('is-flipped')) {
          $('.modal-dialog_wrapper').removeClass('is-flipped');
        } else {
          $('.modal-dialog_wrapper').addClass('is-flipped');
        }
      });

      //登录和注册#signin_form,
      $('#signup_form').submit(function() {
        var userName     = $("#user_name").val(),
            userEmail    = $('#user_email').val(),
            userPassword = $('#user_password').val(),
            code         = $('#captcha').val();

        $.post(api.registerUrl, { user_name:userName, user_email:userEmail, user_password :userPassword, code:code, redirect_url: window.location.href }, function(data) {
            console.log(data);
            if( data.status != 'succ') {
                alert(data.msg);return;
            }
            if(data.redirect_url) window.location.href = data.redirect_url;
        }, 'json')
        return false;
      });

      $('#login_form').submit(function() {
        var userPass = $('#login_password').val(),
            userEmail= $('#login_email').val();

        $.post(api.loginUrl, { user_pass: userPass, user_email:userEmail, redirect_url: window.location.href }, function(data) {
            console.log(data);
            if(!data.status) {
                alert(data.msg);
                return false;
            }
            if (data.redirect_url) window.location.href = data.redirect_url;
        }, 'json')
        //阻止默认事件
        return false;
      });

      //发布商品和文章
      $('.J_UserAction').bind('click', function() {
        $('.J_ActionWrap').toggleClass('hidden');
      });

      //添加到抽屉效果
      $('.current').click(function() {
      	$('.drop-list').css('display', 'block');
      });

      $('.boards .selections a').click(function() {
      	// $(this).css('background-color', 'red');
      	setCurrent($(this).text(), $(this).attr('data-board-id'));
      	$('.drop-list').css('display', 'none');
      })

      //设置当前的分类名称和值
      function setCurrent(name, id) {
      	$('.current .name').text(name);
      	$('.current').parent().attr('data-board-id', id);
      }

      $('#filter_create_board').bind('keyup', filterCreateBoard);
      //创建画板
      function filterCreateBoard() {
        var boardName = $('#filter_create_board').val();
        if (boardName) {
            if (!$('.filtrate:visible').length) {
                $('.boards').css('display','none');
                $('.filtrate').css('display','block');
            }
            $('#new_board_name').text(boardName);
            $('#create_new_board').attr('data-name', boardName);
        } else {
            if ($('.filtrate:visible').length) {
                $('.boards').css('display','block');
                $('.filtrate').css('display','none');
            }
        }
      }

      //切换面板的显示和隐藏
      function toggleShow() {
        if (!$('.filtrate:visible').length) {
            $('.boards').css('display','none');
            $('.filtrate').css('display','block');
        } else {
            $('.boards').css('display','block');
            $('.filtrate').css('display','none');
        }
      }

      //绑定创建画板事件
      $('#create_new_board').bind('click', createBoard);
      //创建画板
      function createBoard() {
        if (!isLogin) {
            $('.login').trigger('click');
            return false;
        };

        var boardName = $('#new_board_name').text();
        if (!boardName) return false;

        $.post(api.createBoardUrl, { "title":boardName }, function(data) {
            if (data.status == 'error') {
                alert(data.msg);
                if(data.redirect_url){
                    window.location.href =  data.redirect_url;
                }
            } else {
                $('.drop-list').css('display','none');
                $('.filtrate').css('display','none');
                $('.boards').css('display','block');
                setCurrent(boardName, data.msg);
                resetCreateBoard();
            }
        }, 'json');
      }

      //重置创建画板的表单
      function resetCreateBoard() {
        $('#filter_create_board').val('');
        $('#new_board_name').text('');
        $('#create_new_board').attr('data-name', '');
      }

      $('.J_DrawrAddGoods').on('click', drawerAddGoods);
      //添加商品到抽屉
      function drawerAddGoods(e) {
        //isLogin 在头部定义
        e.preventDefault();
        if (!isLogin) {
            $('.login').trigger('click');
            return false;
        };

        var goodsId  = $('#J_goodsCoverPreview').attr('data-goods-id');
        var drawerId = $('.board-list').attr('data-board-id');
        var intro    = $('.description').val();

        if (!parseInt(goodsId)) {
            alert('请先选择商品');
            return;
        };

        if (!parseInt(drawerId)) {
            alert('请选择对应的抽屉');
            return;
        };


        //添加商品到抽屉
        var info = {
            'drawer_id' : drawerId,
            'goods_id'  : goodsId,
            'intro'     : intro
        };
        $.post(api.addDrawerGoods, info, function(data) {
            if (data.status != 'succ') {
                alert(data.msg);
                if (data.redirect_url) {
                    window.location.href = data.redirect_url;
                };
            } else {
                $('.description').val('');
                alert('添加成功');
                $('#add_drawer').find('.close').trigger('click');
            }
        }, 'json');
      }


      function checkLogin() {
        return isLogin;
      }

      var hideDrawerTime = null;
      $('.J_GoodsCover').mouseover(function(ev){
        $(this).closest('.J_ItemWrap').find('.card-actions').show();
      });

      $('.J_GoodsCover').mouseout(function(){
        $this= $(this);
        hideDrawerTime = setTimeout(function() {
            $this.closest('.J_ItemWrap').find('.card-actions').hide();
        }, 200)
      });

      $('.card-actions').hover(function() {
        clearTimeout(hideDrawerTime);
      }, function() {
        $(this).closest('.J_ItemWrap').find('.card-actions').hide();
      });

      $('.J_GoodsWrap').on('click', '.J_AddToDrawer', function(ev) {
        ev.preventDefault();
        if (!isLogin) {
            $('.login').trigger('click');
            return false;
        };

        var goodsId = $(this).parent().attr('data-id');
        if (!parseInt(goodsId)) {
            return false;
        };

        var goodsCover = $(this).closest('.J_GoodsWrap').find('.J_GoodsPic');
        var goodsCoverSrc = goodsCover.attr('src');
        var goodsStyle = goodsCover.attr('style');

        $('#J_goodsCoverPreview').attr('src', goodsCoverSrc);
        $('#J_goodsCoverPreview').attr('data-goods-id', goodsId);
        $('#J_goodsCoverPreview').attr('style', goodsStyle);
        $('#add_drawer').trigger('click');
      });

      $('.carousel').carousel();
    });
  </script>
</html>